
$(function(){
	
	new Vue({
		el: '#app',
		data: {
			name: "",
			password: "",
			fullscreenLoading:false,
		},
		created: function() {
		},
		methods: {
			openPasswordMessage() {
			        this.$message.error('密码不能为空');
			},
			openNameMessage(){
				this.$message.error('用户名不能为空');
			},
			getData: function() {
			      if(stringEmpty(this.name)){
					this.openNameMessage();
					 return;
				  }
				  if(stringEmpty(this.password)){
					  this.openPasswordMessage();
					  return;
				  }
				   window.localStorage.clear()
				   this.fullscreenLoading = true;
					let param = {
						username:this.name,
						password:this.password,
					}
					axios({
						url: POSTURL.login,
						method: 'post',
						data: param
					}).then(response => {
						this.fullscreenLoading = false;
						if (response.data.code === 100) {
							 setToken(response.data.result.token)
							 setUUId(response.data.result.uuid)
							 setGrade(response.data.result.grade)
							 if(response.data.result.grade <=1){
								setShopId(response.data.result.shopId) 
								
								
							 }
							 
							 location.href = "./model/home/home.html"	
						}else{
							this.$message.error(response.data.message);
						}
					}).catch(error => {
						this.fullscreenLoading = false;
						this.$message.error('服务器出错!');
					})
				}	
			},
			
	})
	
})





